#pragma once

#include "../umlmodel_global.h"

#include <memory>
#include <vector>

#include "Transition.h"

using std::make_shared;
using std::shared_ptr;
using std::vector;

namespace uml {
class Constraint;
class Operation;

/// <summary>
/// ProtocolTransition
/// A ProtocolTransition specifies a legal Transition for an Operation. Transitions
/// of ProtocolStateMachines have the following information: a pre-condition
/// (guard), a Trigger, and a post-condition. Every ProtocolTransition is associated
/// with at most one BehavioralFeature belonging to the context Classifier of the
/// ProtocolStateMachine.
/// </summary>
class UMLMODEL_EXPORT ProtocolTransition : public Transition {

public: // Constructors and destructors
    explicit ProtocolTransition(const QString& umlType="uml::ProtocolTransition");

public: // JsonSerializable override
    void fromJson(const QJsonObject& json, QStringList& errorList) override;
    void toJson(QJsonObject& json) override;

public: // Methods
public: // Properties
    /// <summary>
    /// postCondition getter
    /// Specifies the post condition of the Transition which is the Condition that
    /// should be obtained once the Transition is triggered. This post condition is part
    /// of the post condition of the Operation connected to the Transition.
    /// </summary>
    shared_ptr<Constraint> postCondition() const;

    /// <summary>
    /// postCondition setter
    /// Specifies the post condition of the Transition which is the Condition that
    /// should be obtained once the Transition is triggered. This post condition is part
    /// of the post condition of the Operation connected to the Transition.
    /// </summary>
    void setPostCondition(shared_ptr<Constraint> value);

    /// <summary>
    /// preCondition getter
    /// Specifies the precondition of the Transition. It specifies the Condition that
    /// should be verified before triggering the Transition. This guard condition added
    /// to the source State will be evaluated as part of the precondition of the
    /// Operation referred by the Transition if any.
    /// </summary>
    shared_ptr<Constraint> preCondition() const;

    /// <summary>
    /// preCondition setter
    /// Specifies the precondition of the Transition. It specifies the Condition that
    /// should be verified before triggering the Transition. This guard condition added
    /// to the source State will be evaluated as part of the precondition of the
    /// Operation referred by the Transition if any.
    /// </summary>
    void setPreCondition(shared_ptr<Constraint> value);

    /// <summary>
    /// referreds getter
    /// This association refers to the associated Operation. It is derived from the
    /// Operation of the CallEvent Trigger when applicable.
    /// </summary>
    vector<shared_ptr<Operation>>& referreds();

private: // Fields
    /// <summary>
    /// postCondition
    /// Specifies the post condition of the Transition which is the Condition that
    /// should be obtained once the Transition is triggered. This post condition is part
    /// of the post condition of the Operation connected to the Transition.
    /// </summary>
    shared_ptr<Constraint> postCondition_;

    /// <summary>
    /// preCondition
    /// Specifies the precondition of the Transition. It specifies the Condition that
    /// should be verified before triggering the Transition. This guard condition added
    /// to the source State will be evaluated as part of the precondition of the
    /// Operation referred by the Transition if any.
    /// </summary>
    shared_ptr<Constraint> preCondition_;

    /// <summary>
    /// referreds
    /// This association refers to the associated Operation. It is derived from the
    /// Operation of the CallEvent Trigger when applicable.
    /// </summary>
    vector<shared_ptr<Operation>> referreds_;

};

} // namespace uml
